<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 事件日志控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\service\EventLogService;
use think\Request;

class EventLogController extends VerifyController
{
    protected $eventLogService;

    public function __construct()
    {
        parent::__construct();
        $this->eventLogService = new EventLogService();
    }

    /**
     * 查询日志
     * @param Request $request
     * @return \think\Response
     */
    public function select(Request $request)
    {
        $param = $request->param();
        try {
            $data = $this->eventLogService->select($param);
            return json(success_response('', $data));
        } catch (\Throwable $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }


    /**
     * 获得格式化的日志
     * @param Request $request
     * @return \think\Response
     */
    public function getFormattedEventLog(Request $request)
    {
        $param = $request->param();
        $data = $this->eventLogService->getEventLogFormatted($param['param']);
        return json(success_response('', $data));
    }
}
